<?php
class UserController
{
    public function __construct(UserRepository $user)
    {
        $this->user = $user;
    }

    public function index()
    {
        $user = $this->user->all();
        echo $user;
    }
}
require 'UserRepository.php';
$user= new UserController(new UserRepository());
$user->index();